#include "basic.h"

static uint32_t life_num=0;

uint8_t ascii2digit(char c)
{
	char base;
	if (c >= '0' && c <= '9')
		base = '0';
	else if (c >= 'a' && c <= 'f')
		base = 'a' - 10;
	else if (c >= 'A' && c <= 'F')
		base = 'A' - 10;
	else
		base = c;
	return (uint8_t)(c - base);
}

BOLT(life_set, "life set <number>")
{
	uint32_t num;
	if(!str2u32(pop_argz(),&num)){
		printf("invalid life number.\n");
		return;
	}	
	life_num=num;
}

BOLT(ip_set_len, "ip set length <length>")
{
  uint16_t ip_len;
  const char *argz = pop_argz();
	if(argz != NULL && str2u16(argz,&ip_len)){
		ip_set_len(ip_len);
	}	
}

BOLT(ip_show, "ip show")
{
  printf ("IP Length: %u\n", ip_get_len());
  printf ("=========\n");
  ip_show();
}

BOLT(prot_reset, "prot reset")
{
  prot_reset();
}

BOLT(prot_clean, "prot clean")
{
  prot_clean();
}

BOLT_PROFILE(basic, "", basic_profile, desc)
{
  uint16_t len = ip_get_len();
  if (len != DEFAULT_IP_LEN)
    cmd_load_profile(desc, "ip set length %u\n", len);
}


